package com.adu.demo.controller;
import java.util.List;
import com.adu.demo.domain.Tag;
import com.adu.demo.service.Impl.TagService;
import com.adu.demo.util.JsonResult;
import com.adu.demo.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
                                            // 测试
@RestController
@RequestMapping("/Tag")
public class TagController extends BaseController {
    @Autowired
    private TagService tagService;

    @GetMapping("/getList")
    public Result getList(@RequestBody Tag tag){
        startPage();
        List<Tag> tagList=tagService.getList(tag);
        return JsonResult.OK(200,"success",tagList);
    }

    @GetMapping("/getById")
    public Result getById(Long id){
        Tag tag=tagService.getById(id);
        return JsonResult.OK(200,"success",tag);
    }
    @PostMapping("/save")
    public Result save(@RequestBody Tag tag){
        tagService.save(tag);
        return JsonResult.OK(200,"success");
    }
    @DeleteMapping("/removeBatch")
    public Result remove(@PathVariable Long[] ids){
        tagService.deleteByIds(ids);
        return JsonResult.OK(200,"success");
    }
    @DeleteMapping("/remove")
    public Result remove(@PathVariable Long id){
        tagService.deleteById(id);
        return JsonResult.OK(200,"success");
    }
    @GetMapping("/update")
    public Result update(@RequestBody Tag tag){
        tagService.update(tag);
        return JsonResult.OK(200,"success");
    }
}